from typing import Optional, List
import os

AK = '2jCwbiCWReSVlPbt53f9pYhP'
SK = 'dwJ8BULLCsBMXsmtjyxNI8hkw4y0HPXq'
os.environ['QIANFAN_AK'] = AK
os.environ['QIANFAN_SK'] = SK
from langchain.agents import load_tools, initialize_agent, AgentType
from langchain.chat_models import QianfanChatEndpoint
from langchain_community.chat_models import QianfanChatEndpoint
# 实例化大模型
llm = QianfanChatEndpoint()
# 设置工具
tools = load_tools(['wikipedia', 'llm-math'], llm=llm)
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
print('agent', agent)
# 准备提示词
from langchain import PromptTemplate

prompt_template = '你给我查一下,2024年4月中旬开始的美股暴跌会持续多久?'
prompt = PromptTemplate.from_template(prompt_template)
print('prompt-->', prompt)
agent.run(prompt)
